package com.iflytek.universitymanagement.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.iflytek.universitymanagement.domain.CourseResource;
import com.iflytek.universitymanagement.domain.Resource;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ResourceMapper extends BaseMapper<Resource> {


    // 查询所有资源，并返回课程名称
    @Select("SELECT r.resource_id, r.course_id, r.resource_name, r.resource_type, r.url, r.description, c.course_name " +
            "FROM resources r " +
            "JOIN course c ON r.course_id = c.course_id")
    List<CourseResource> getAllResourcesWithCourseName();
    List<Resource> selectByResourceName(String resourceName);

}